<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            outline: none;
            font-family: 'Poppins', sans-serif;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            background: url(../images/24.jpg);
        }

        .container {
            width: 330px;
            background: #fff;
            border-radius: 5px;
            text-align: center;
            padding: 50px 35px 10px 35px;
        }

        .container header {
            font-size: 35px;
            font-weight: 600;
            margin: 0 0 30px 0;
        }

        .container .form-outer {
            width: 100%;
            overflow: hidden;
        }

        .form-outer form {
            display: flex;
            width: 400%;
        }

        .form-outer form .page {
            width: 25%;
            /* 过渡时间的对象名称 */
            transition: margin-left 0.3s ease-in-out;
        }

        .form-outer form .page .title {
            text-align: left;
            font-size: 25px;
            font-weight: 500;
        }

        .form-outer form .page .field {
            height: 45px;
            width: 330px;
            margin: 45px 0;
            display: flex;
            position: relative;
        }

        .form-outer form .page .field .label {
            position: absolute;
            top: -30px;
            font-weight: 500;
        }

        .form-outer form .page .field input {
            height: 100%;
            width: 100%;
            border: 1px solid lightgrey;
            border-radius: 5px;
            font-size: 18px;
            padding-left: 15px;
        }

        .form-outer form .page .field button {
            width: 100%;
            height: calc(100% + 5px);
            margin-top: -20px;
            border: none;
            background: #333;
            border-radius: 5px;
            color: #fff;
            font-size: 18px;
            font-weight: 600;
            letter-spacing: 1px;
            text-transform: uppercase;
            cursor: pointer;
            transition: .3s ease;
        }

        .form-outer form .page .field select {
            width: 100%;
            padding-left: 10px;
            font-size: 17px;
            font-weight: 500;
        }

        .form-outer form .page .field button:hover {
            background: #000;
        }

        .form-outer form .page .btns button {
            margin-top: -20px !important;
        }

        .form-outer form .page .btns button.prev {
            margin-right: 3px;
            font-size: 17px;
        }

        .form-outer form .page .btns button.next {
            margin-left: 3px;
        }

        .container .progress-bar {
            display: flex;
            margin: 40px 0;
        }

        .container .progress-bar .step {
            position: relative;
            text-align: center;
            width: 100%;
        }

        .container .progress-bar .step p {
            font-size: 18px;
            font-weight: 500;
            color: #000;
            margin-bottom: 8px;
        }

        .container .progress-bar .step p.active {
            color: #d43f8d;
        }

        .container .progress-bar .step .bullet {
            position: relative;
            height: 25px;
            width: 25px;
            border: 2px solid #000;
            display: inline-block;
            border-radius: 50%;
            font-size: 17px;
            line-height: 25px;
            transition: .2s;
        }

        .container .progress-bar .step .bullet.active {
            border-color: #d43f8d;
            background: #d43f8d;
        }

        .container .progress-bar .step:last-child .bullet::before,
        .container .progress-bar .step:last-child .bullet::after {
            display: none;
        }

        .container .progress-bar .step .bullet::before,
        .container .progress-bar .step .bullet::after {
            position: absolute;
            content: '';
            bottom: 11px;
            right: -51px;
            height: 3px;
            width: 44px;
            background: #333;
        }

        .container .progress-bar .step .bullet.active::after {
            background: #d43f8d;
            transform: scaleX(0);
            /* 动画初始是由中间向两边 改为由左至右 */
            transform-origin: left;
            /* forwards不同于infinite  而是只生效一次 */
            animation: animate 0.3s linear forwards;
        }

        @keyframes animate {
            100% {
                transform: scaleX(1);
            }
        }

        .container .progress-bar .step .bullet span {
            font-weight: 500;
            font-size: 17px;
            line-height: 25px;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
        }

        .container .progress-bar .step .bullet.active span {
            display: none;
        }

        .container .progress-bar .step .check {
            position: absolute;
            left: 50%;
            top: 70%;
            font-size: 15px;
            transform: translate(-50%, -50%);
            display: none;
        }

        .container .progress-bar .step .check.active {
            display: block;
            color: #fff;
        }
    </style>
</head>

<body>
    <div class="container">
        <header>Signup Form</header>
        <div class="progress-bar">
            <div class="step">
                <p>Name</p>
                <div class="bullet"><span>1</span></div>
                <div class="check fa fa-check"></div>
            </div>
            <div class="step">
                <p>Contact</p>
                <div class="bullet"><span>2</span></div>
                <div class="check fa fa-check"></div>
            </div>
            <div class="step">
                <p>Birth</p>
                <div class="bullet"><span>3</span></div>
                <div class="check fa fa-check"></div>
            </div>
            <div class="step">
                <p>Submit</p>
                <div class="bullet"><span>4</span></div>
                <div class="check fa fa-check"></div>
            </div>
        </div>
        <div class="form-outer">
            <form action="#">
                <div class="page slidepage">
                    <div class="title">Basic Info:</div>
                    <div class="field">
                        <div class="label">First Name</div>
                        <input type="text">
                    </div>
                    <div class="field">
                        <div class="label">Last Name</div>
                        <input type="text">
                    </div>
                    <div class="field nextBtn">
                        <button>Next</button>
                    </div>
                </div>
                <div class="page">
                    <div class="title">Contact Info:</div>
                    <div class="field">
                        <div class="label">Email Address</div>
                        <input type="text">
                    </div>
                    <div class="field">
                        <div class="label">Phone Number</div>
                        <input type="number">
                    </div>
                    <div class="field btns">
                        <button class="prev-1 prev">Previous</button>
                        <button class="next-1 next">Next</button>
                    </div>
                </div>
                <div class="page">
                    <div class="title">Date of Birth:</div>
                    <div class="field">
                        <div class="label">Date</div>
                        <input type="text">
                    </div>
                    <div class="field">
                        <div class="label">Gender</div>
                        <select>
                            <option>Male</option>
                            <option>Female</option>
                            <option>Other</option>
                        </select>
                    </div>
                    <div class="field btns">
                        <button class="prev-2 prev">Previous</button>
                        <button class="next-2 next">Next</button>
                    </div>
                </div>
                <div class="page">
                    <div class="title">Login Details:</div>
                    <div class="field">
                        <div class="label">Username</div>
                        <input type="text">
                    </div>
                    <div class="field">
                        <div class="label">Password</div>
                        <input type="password">
                    </div>
                    <div class="field btns">
                        <button class="prev-3 prev">Previous</button>
                        <button class="submit next">Submit</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>
<script>
    const slidePage = document.querySelector(".slidepage");
    const firtNextBtn = document.querySelector(".nextBtn");
    const prevBtnSec = document.querySelector(".prev-1");
    const nextBtnSec = document.querySelector(".next-1");
    const prevBtnThird = document.querySelector(".prev-2");
    const nextBtnThird = document.querySelector(".next-2");
    const prevBtnFourth = document.querySelector(".prev-3");
    const submitBtn = document.querySelector(".submit");
    const progressText = document.querySelectorAll(".step p");
    const progressCheck = document.querySelectorAll(".step .check");
    const bullet = document.querySelectorAll(".step .bullet");
    let max = 4;
    let current = 1;

    firtNextBtn.addEventListener("click", () => {
        slidePage.style.marginLeft = "-25%"
        bullet[current - 1].classList.add("active");
        progressText[current - 1].classList.add("active");
        progressCheck[current - 1].classList.add("active");
        current += 1;
    });
    nextBtnSec.addEventListener("click", () => {
        slidePage.style.marginLeft = "-50%"
        bullet[current - 1].classList.add("active");
        progressText[current - 1].classList.add("active");
        progressCheck[current - 1].classList.add("active");
        current += 1;
    });
    nextBtnThird.addEventListener("click", () => {
        slidePage.style.marginLeft = "-75%"
        bullet[current - 1].classList.add("active");
        progressText[current - 1].classList.add("active");
        progressCheck[current - 1].classList.add("active");
        current += 1;
    });
    submitBtn.addEventListener("click", () => {
        bullet[current - 1].classList.add("active");
        progressText[current - 1].classList.add("active");
        progressCheck[current - 1].classList.add("active");
        current += 1;
        setTimeout(() => {
            alert("You're successfully Signed up");
            location.reload();
        }, 800);
    });

    prevBtnSec.addEventListener("click", () => {
        slidePage.style.marginLeft = "0%"
        bullet[current - 2].classList.remove("active");
        progressText[current - 2].classList.remove("active");
        progressCheck[current - 2].classList.remove("active");
        current -= 1;
    });
    prevBtnThird.addEventListener("click", () => {
        slidePage.style.marginLeft = "-25%"
        bullet[current - 2].classList.remove("active");
        progressText[current - 2].classList.remove("active");
        progressCheck[current - 2].classList.remove("active");
        current -= 1;
    });
    prevBtnFourth.addEventListener("click", () => {
        slidePage.style.marginLeft = "-50%"
        bullet[current - 2].classList.remove("active");
        progressText[current - 2].classList.remove("active");
        progressCheck[current - 2].classList.remove("active");
        current -= 1;
    });
</script>

</html>